<?php
	class onlineuser_widget extends Widget 
	{
		public function display($args)
		{
			$data=array();
			$onlineuser=get_users_online();
			//print_r($onlineuser);
			$myfriends=$this->general_model->get_jointable("zap_friends","zap_member","*","zap_friends.friend_id=zap_member.userid","zap_friends.userid = ".$args['userid']." and zap_member.activated = 1");
			//print_r($myfriends);
			$data['onlineuser']=array();
			foreach($myfriends as $friend)
			{
				if (array_key_exists($friend['userid'], $onlineuser))
				{
					$data['onlineuser'][]=array(
									"userid"=>$friend['userid'],
									"firstname"=>$friend['firstname'],
									"photo"=>$friend['photo'],
									"online"=>1);
				}
				else
				{
					$data['onlineuser'][]=array(
									"userid"=>$friend['userid'],
									"firstname"=>$friend['firstname'],
									"photo"=>$friend['photo'],
									"online"=>0);
				}
			}
			
			/*foreach($onlineuser as $key=>$value)
			{
				
				$data['onlineuser'][]=$this->general_model->select_val("zap_member","userid,firstname,photo","userid ='".$key."'")	;	
			}*/
			//print_r($data['addmateuser']);
			$this->load->view('widgets/onlineuser',$data);	
		}
	}
?>